import { fromJS } from 'immutable'
import { THEME } from '../../constants/constants'
import storageUtils from '../../utils/storageUtils'

export const APP_ACTION = 'app_action'

const initialState = fromJS({
  theme: storageUtils.getValue(storageUtils.THEME) || THEME.NIGHT,
  wsConnectSuccess: false
})

export default (state = initialState, action) => {
  if (action.type === APP_ACTION) {
    return state.merge(action.data)
  }
  return state
}
